layui.use(['table', 'layer','laydate'], function () {
    var table = layui.table;
    var layer = layui.layer;
    var laydate = layui.laydate;
    laydate.render({
        elem: '#applyTime'
    });
    var branchTable = table.render({
        elem: '#assignTable'
        // ,height: 315
        // ,url: baseURL + 'sys/branch/list' //数据接口
        , page: true //开启分页


        , cols: [[ //表头
            {field: 'clientNum', title: '商户编号', sort: true}
            , {field: 'clientName', title: '商户名称', minWidth: '150'}
            , {field: 'applyTool', title: '申领机具', minWidth: '150'}
            , {field: 'deposit', title: '押金金额', minWidth: '70'}
            , {field: 'assignStatus', title: '分配状态', minWidth: '70'}
            , {field: 'applyTime', title: '申请时间', minWidth: '90'}
            , { width: 178, title: '操作',align: 'center', toolbar: '#barDemo'}
        ]]

        , data: [{
            "clientNum": "21000092"
            , "clientName": "恒生电子股份有限公司"
            , "applyTool": "扫码枪X1,智能POS机X1，台牌X2…"
            , "deposit": "2000"
            , "assignStatus": "已分配"
            , "applyTime": "2017-12-11 09:55"
        }, {
            "clientNum": "21000092"
            , "clientName": "恒生电子股份有限公司"
            , "applyTool": "扫码枪X2"
            , "deposit": "2000"
            , "assignStatus": "已分配"
            , "applyTime": "2017-12-11 09:55"
        },
            {
                "clientNum": "21000092"
                , "clientName": "恒生电子股份有限公司"
                , "applyTool": "台牌X2"
                , "deposit": "2000"
                , "assignStatus": "已分配"
                , "applyTime": "2017-12-11 09:55"
            },
            {
                "clientNum": "21000092"
                , "clientName": "恒生电子股份有限公司"
                , "applyTool": "扫码枪X1,智能POS机X1，台牌X2…"
                , "deposit": "2000"
                , "assignStatus": "已分配"
                , "applyTime": "2017-12-11 09:55"
            },
            {
                "clientNum": "21000092"
                , "clientName": "恒生电子股份有限公司"
                , "applyTool": "扫码枪X1,智能POS机X1，台牌X2…"
                , "deposit": "2000"
                , "assignStatus": "已分配"
                , "applyTime": "2017-12-11 09:55"
            },
            {
                "clientNum": "21000092"
                , "clientName": "恒生电子股份有限公司"
                , "applyTool": "台牌X1"
                , "deposit": "2000"
                , "assignStatus": "已分配"
                , "applyTime": "2017-12-11 09:55"
            }]

    });



    //监听工具条
    table.on('tool(branchTableFilter)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
        var data = obj.data; //获得当前行数据
        var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
        var tr = obj.tr; //获得当前行 tr 的DOM对象

        if (layEvent === 'detail') { //查看
            window.location = '../toolmanage/toolAssign-detail.html'
            //$.post('merchant-detail.html', function (data) {
            //    layer.open({
            //        type: 1,
            //        area: ['1000px', '460px'],
            //        content: data
            //    });
            //}, 'html');
        }
    });





});